home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / asmutil / asm_n_z.zip / PDSW.ASM < prev    next >
Assembly Source File  |  1985-08-27  |  7KB  |  415 lines

  1. bell    equ    7
  2. cr    equ    13
  3. lf    equ    10
  4. tab    equ    9
  5. LINES    equ    48
  6. eol    equ    '$'
  7. esc    equ    27
  8. ;
  9. ;---------------
  10. ;
  11. LPRINT    MACRO    L1,L2,L3,L4,L5,L6    ;LPRINT A CHARACTER MACRO
  12.  
  13. IFNB    <L1>            ;SET AL TO THE OPTIONAL PARAMETER
  14.     MOV    AL,L1
  15.     ENDIF
  16.     CALL    LPRINT1        ;PRINT THE CHAR
  17.  
  18. IFNB    <L2>
  19.     LPRINT    L2,L3,L4,L5,L6
  20.     ENDIF
  21.  
  22.           ENDM
  23. ;
  24. ;---------------
  25. ;
  26. FORM_FEED    macro
  27.     lprint    12
  28.     endm
  29. ;
  30. ;---------------
  31. ;
  32. SW_LF    macro
  33.     lprint    esc,'J',24,cr
  34.     endm
  35. ;
  36. ;---------------
  37. ;
  38. SW_SET_BIT    macro
  39.     lprint    esc,'K',cl,ch
  40.     endm          
  41. ;
  42. ;---------------
  43. ;
  44. CSEG    SEGMENT    byte public 'CODE'
  45.     ASSUME    CS:CSEG,DS:CSEG,ES:CSEG
  46.  
  47.  
  48.     ORG    81H
  49. fname    label    byte
  50.     ORG    100H
  51. START    PROC    NEAR
  52.     jmp    start1
  53.  
  54.     DB    CR,'Public Domain SideWays (pd)1985 by Donavon Kuhn ',cr,lf,1AH
  55. ;
  56. handle        dw    0
  57. char_flag    db    0
  58. end_of_file    db    0
  59. column        dw    0
  60. row        db    0
  61. ;
  62. start1:
  63.     lea    dx,inst
  64.     mov    ah,9
  65.     int    21h
  66.  
  67.     xor    bh,bh
  68.     mov    bl,ds:[80h]        ;get length of input filename
  69.     lea    di,fname
  70.     mov    byte ptr [di][bx],0    ;make into an ASCIIZ string
  71.  
  72. ;    open    i,1,fname
  73.     lea    di,fname-1        ;strip leading spaces
  74. splp:
  75.     inc    di
  76.     cmp    byte ptr [di],' '
  77.     jz    splp
  78.  
  79.     cmp    byte ptr [di],0
  80.     jz    usage
  81.     cmp    byte ptr [di],'?'
  82.     jnz    no_usage
  83.  
  84. usage:
  85.     lea    dx,usagestr
  86.     jmp    error1
  87.  
  88. no_usage:
  89.     mov    dx,di
  90.     mov    ah,3dh
  91.     mov    al,0
  92.     int    21h
  93.     mov    handle,ax
  94.     jnc    no_open_err1
  95.     jmp    error
  96.  
  97. no_open_err1:
  98.     lea    dx,pausestr
  99.     mov    ah,9
  100.     int    21h
  101.  
  102. no_open_err:
  103.  
  104.     lea    di,line_ptr        ;fill text buffer with spaces
  105.     mov    al,0
  106.     cld
  107.     mov    cx,LINES*1024+LINES*2
  108.     rep    stosb
  109.  
  110.     mov    row,0
  111.     lea    di,text_buffer
  112.     mov    bx,0
  113.  
  114. lflp:
  115.     inc    row
  116.     cmp    row,LINES+1        ;reached max lines/page yet?
  117.     jb    not_yet
  118.     jmp    read_done
  119.  
  120. not_yet:
  121.     mov    line_ptr[bx],di        ;pointer to the beginning of the line
  122.     add    bx,2            ;don't wreck BX!
  123.     mov    column,0
  124.  
  125. charlp:
  126.     push    bx
  127.     mov    bx,handle
  128.     mov    ah,3fh            ;read char from file
  129.     mov    cx,1
  130.     lea    dx,inbuff
  131.     int    21h
  132.     pop    bx
  133.     cmp    ax,1
  134.     jz    read_ok
  135. donejmp:
  136.     mov    end_of_file,1
  137.     jmp    read_done
  138.  
  139. read_ok:
  140.     mov    al,byte ptr inbuff    ;char in AL
  141.  
  142.     cmp    al,'Z'-64        ;if CTRL-Z
  143.     jz    donejmp    
  144.  
  145.     cmp    al,lf            ;if a new line
  146.     jz    lflp
  147.  
  148.     cmp    al,cr
  149.     jnz    nocr
  150.     mov    al,0
  151.           jmp    place
  152. nocr:
  153.     cmp    al,TAB
  154.     jnz    notab
  155.     mov    al,' '
  156. tablp:    
  157.     mov    [di],al
  158.     inc    di
  159.     inc    column
  160.     call    colwidth
  161.     test    column,7
  162.     jnz    tablp    
  163.     jmp    charlp
  164.  
  165. notab:
  166.     cmp    al,'L'-64
  167.     jz    read_done
  168.  
  169.     cmp    al,32
  170.     jb    spacectrl
  171.  
  172. place: 
  173.      mov    [di],al
  174.     inc    di
  175.     inc    column
  176.     call    colwidth
  177. spacectrl:
  178.     jmp    charlp
  179.  
  180.  
  181. colwidth:
  182.     cmp    column,1024
  183.     jb    widthok
  184.     lea    dx,toowide
  185.     jmp    error1
  186. widthok:
  187.     ret
  188.  
  189.  
  190.  
  191. read_done:
  192.     mov    ah,1
  193.     int    16h
  194.     jz    read_done1
  195.  
  196.     mov    ah,0
  197.     int    16h
  198.     cmp    al,27
  199.     jne    read_done1
  200.  
  201.     jmp    all_done
  202.  
  203. read_done1:
  204.     mov    cx,LINES*10
  205.     SW_SET_BIT
  206.  
  207.     mov    cx,LINES
  208.     lea    si,line_ptr+(LINES*2)-2
  209.     mov    char_flag,0
  210. prlp:
  211.     mov    al,' '
  212.     mov    di,[si]
  213.     cmp    di,0
  214.     jz    printit
  215.     mov    al,[di]
  216.     cmp    al,0
  217.     jnz    notzero
  218.     mov    word ptr [si],0
  219.     mov    al,' '
  220.     jmp    printit
  221.  
  222. notzero:
  223.     inc    word ptr [si]
  224.     mov    char_flag,1
  225.  
  226. printit:
  227.     sub    al,32
  228.     mov    ah,8
  229.     mul    ah
  230.     lea    di,swbit
  231.     add    di,ax
  232.  
  233.     push    cx
  234.     mov    cx,8
  235. cxlp:
  236.     mov    al,[di]
  237.     inc    di
  238.     lprint
  239.     loop    cxlp
  240.     pop    cx
  241.  
  242.     lprint    0,0
  243.  
  244.     sub    si,2
  245.     loop    prlp
  246.  
  247.     SW_LF
  248.  
  249.     cmp    char_flag,0
  250.     jz    next_page
  251.     jmp    read_done
  252.  
  253. next_page:
  254.  
  255.     FORM_FEED
  256.  
  257.     cmp    end_of_file,0
  258.     jnz    all_done
  259.     jmp    no_open_err
  260.  
  261. all_done:
  262.     mov    ax,4c00h
  263.     int    21h
  264.  
  265. ;
  266. ;-----------------
  267. ;
  268. LPRINT1    PROC    NEAR        ;LPRINT CHAR IN AL
  269.     push    ax
  270.     push    dx
  271.     XOR    DX,DX
  272.     XOR    AH,AH
  273.     int    17h
  274.     pop    dx
  275.     pop    ax
  276.     ret
  277. LPRINT1 ENDP
  278. ;
  279. ;-----------------
  280. ;
  281. inbuff    db    0
  282.  
  283. inst    DB    'Public Domain SideWays (pd)1985 by Donavon Kuhn '
  284.     db    cr,lf,cr,lf,eol
  285.  
  286. toowide    db    'Line width cannot excede 1024 characters.',bell,cr,lf,eol
  287. errmsg    db    'File not Found or Open Error.',bell,cr,lf,eol
  288. pausestr    db    'Press ESC to Cancel',eol
  289.  
  290.  
  291. error:
  292.     lea    dx,errmsg
  293. error1:
  294.     mov    ah,9
  295.     int    21h
  296.     mov    ax,4c01h            ;error with errorlevel 1
  297.     int    21h
  298. ;
  299. ;
  300. swbit:
  301.     DB    0,0,0,0,0,0,0,0
  302.     DB    0,16,0,16,16,56,56,16
  303.     DB    0,0,0,0,0,36,36,36
  304.     DB    0,36,36,126,36,126,36,36
  305.     DB    0,24,124,2,60,64,62,24
  306.     DB    0,70,38,16,8,100,98,0
  307.     DB    0,118,136,136,86,48,72,48
  308.     DB    0,0,0,0,0,32,16,16
  309.     DB    0,16,32,64,64,64,32,16
  310.     DB    0,32,16,8,8,8,16,32
  311.     DB    0,0,68,56,254,56,68,0
  312.     DB    0,0,16,16,124,16,16,0
  313.     DB    32,16,16,0,0,0,0,0
  314.     DB    0,0,0,0,126,0,0,0
  315.     DB    0,16,16,0,0,0,0,0
  316.     DB    0,64,32,16,8,4,2,0
  317.     DB    0,60,98,82,74,70,66,60
  318.     DB    0,124,16,16,16,80,48,16
  319.     DB    0,126,66,48,12,2,66,60
  320.     DB    0,60,66,2,28,2,66,60
  321.     DB    0,28,8,254,72,40,24,8
  322.     DB    0,60,66,2,2,124,64,126
  323.     DB    0,60,66,66,124,64,32,28
  324.     DB    0,16,16,16,8,4,66,126
  325.     DB    0,60,66,66,60,66,66,60
  326.     DB    0,56,4,2,62,66,66,60
  327.     DB    0,16,16,0,0,16,16,0
  328.     DB    32,16,16,0,0,16,16,0
  329.     DB    0,8,16,32,64,32,16,8
  330.     DB    0,0,126,0,0,126,0,0
  331.     DB    0,16,8,4,2,4,8,16
  332.     DB    0,8,0,8,4,2,66,60
  333.     DB    0,60,64,94,82,94,66,60
  334.     DB    0,66,66,126,66,66,36,24
  335.     DB    0,124,34,34,60,34,34,124
  336.     DB    0,28,34,64,64,64,34,28
  337.     DB    0,120,36,34,34,34,36,120
  338.     DB    0,126,34,40,56,40,34,126
  339.     DB    0,112,32,40,56,40,34,126
  340.     DB    0,30,34,78,64,64,34,28
  341.     DB    0,66,66,66,126,66,66,66
  342.     DB    0,56,16,16,16,16,16,56
  343.     DB    0,56,68,68,4,4,4,14
  344.     DB    0,99,36,40,48,40,36,98
  345.     DB    0,126,34,32,32,32,32,112
  346.     DB    0,65,65,65,65,73,85,99
  347.     DB    0,66,66,66,70,74,82,98
  348.     DB    0,24,36,66,66,66,36,24
  349.     DB    0,112,32,32,60,34,34,124
  350.     DB    0,3,60,74,66,66,66,60
  351.     DB    0,114,36,40,60,34,34,124
  352.     DB    0,60,66,2,60,64,66,60
  353.     DB    0,28,8,8,8,8,73,127
  354.     DB    0,60,66,66,66,66,66,66
  355.     DB    0,8,20,34,65,65,65,65
  356.     DB    0,54,73,73,73,65,65,65
  357.     DB    0,65,34,20,8,20,34,65
  358.     DB    0,28,8,8,8,20,34,65
  359.     DB    0,127,33,16,8,4,66,127
  360.     DB    0,120,64,64,64,64,64,120
  361.     DB    0,2,4,8,16,32,64,128
  362.     DB    0,120,8,8,8,8,8,120
  363.     DB    0,0,0,0,130,68,40,16
  364.     DB    255,0,0,0,0,0,0,0
  365.     DB    0,0,0,0,0,8,16,16
  366.     DB    0,63,66,62,2,60,0,0
  367.     DB    0,46,49,49,46,32,32,96
  368.     DB    0,60,66,64,66,60,0,0
  369.     DB    0,59,70,70,58,2,2,6
  370.     DB    0,60,64,126,66,60,0,0
  371.     DB    0,56,16,16,56,16,18,12
  372.     DB    124,2,62,66,66,61,0,0
  373.     DB    0,98,34,34,50,44,32,96
  374.     DB    0,56,16,16,16,48,0,16
  375.     DB    60,66,66,2,2,6,0,2
  376.     DB    0,38,40,48,40,36,32,96
  377.     DB    0,56,16,16,16,16,16,48
  378.     DB    0,73,73,73,73,118,0,0
  379.     DB    0,66,66,66,98,92,0,0
  380.     DB    0,60,66,66,66,60,0,0
  381.     DB    112,32,44,50,50,108,0,0
  382.     DB    14,4,52,76,76,54,0,0
  383.     DB    0,112,32,34,50,108,0,0
  384.     DB    0,124,2,60,64,62,0,0
  385.     DB    0,12,18,16,16,124,16,16
  386.     DB    0,58,70,66,66,66,0,0
  387.     DB    0,8,20,34,65,65,0,0
  388.     DB    0,54,73,73,73,65,0,0
  389.     DB    0,68,40,16,40,68,0,0
  390.     DB    124,2,62,66,66,66,0,0
  391.     DB    0,124,32,16,8,124,0,0
  392.     DB    0,12,16,16,96,16,16,12
  393.     DB    0,16,16,16,0,16,16,16
  394.     DB    0,48,8,8,6,8,8,48
  395.     DB    0,0,0,0,0,0,76,50
  396.     DB    0,127,65,65,34,20,8,0
  397. ;
  398. ;
  399.  
  400. line_ptr    label    word
  401. usagestr:
  402.     db    cr,lf
  403.     db    'Usage:  PDSW filespec',cr,lf,cr,lf
  404.     db    'Where:  filespec is the name of a file to be printed',cr,lf
  405.     db    '        sideways to an Epson printer on LPT1:',cr,lf,eol
  406.  
  407. text_buffer    equ line_ptr+LINES*2
  408.  
  409. ;
  410. ;
  411. START    ENDP
  412. CSEG    ENDS
  413.     END    START
  414.  
  415.